import Base from "./Base";
import utils from "src/utils";
import { Props } from "src/types/shape";
// import { shapeType } from "src/types/drawBoard";

export interface ArcProps {
  x: number;
  y: number;
  radius: number;
  borderWidth?: number;
  borderColor?: string;
  bgcolor?: string;
}

export default class extends Base {
  constructor(option: ArcProps) {
    super()
    utils.object.Assign(option, this.props)
    this.props.width = option.radius * 2
    this.props.height = option.radius * 2
  }
  draw(ctx: CanvasRenderingContext2D, osCtx: OffscreenCanvasRenderingContext2D): void {
    const { x, y, radius } = this.props

    ctx.save()

    this.transform(ctx)
    ctx.beginPath()
    this.initOptions(ctx, 1)

    ctx.arc(x + radius, y + radius, radius, 0, 2 * Math.PI, true)
    ctx.closePath()
    ctx.fill()

    ctx.restore()

    // 镜像画布
    this.drawMirror(osCtx)
  }
  setProps(option: Props): void {
    super.setProps(option)
    this.props.width = option.radius * 2
    this.props.height = option.radius * 2
  }
}